package com.movie.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * @author Liu Jiaquan
 * @Description
 * @date 2024/8/5 20:46
 */

public class OrderNumberGenerator {

    public static void main(String[] args) {
        System.out.println(generateOrderNumber());
    }

    public static String generateOrderNumber() {
        // 获取当前时间戳
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String timestamp = sdf.format(new Date());

        // 生成一个随机的6位数
        Random random = new Random();
        int randomNumber = 100000 + random.nextInt(900000);

        // 拼接时间戳和随机数生成订单号
        return timestamp + randomNumber;
    }
}

